<?php
/********************************************************
 *
 * 此文件的作用:
 *		公告表的入口
 *
 * @copyright Copyright (c) 2008-2009
 * @author 刘昌功 lcg635@126.com
 *
 ********************************************************/
defined('APP_DIR') or die('404 Not Found');

FLEA::loadClass('Common_Table');

class Table_Teacher extends Common_Table {
    var $tableName = 'teacher';
    var $primaryKey = 'user_id';
    
    var $belongsTo = array(
    	array(
			'tableClass' => 'Table_User',
			'foreignKey'=>'user_id',
			'mappingName'=>'user',
			'enabled' => false
		)
    );

	function form( $type = 'update', $data = null) {
		$this->_ui = FLEA::initWebControls();
		switch( $type ){
			case 'check': return $this->checkForm($data); break;
			case 'register': return $this->registerForm($data);break;
			case 'update': return $this->updateForm($data); break;
		}
	}
	
	function checkForm($data = null) {
		$form = array(
			'teacher_id' => $this->_ui->control('Textbox','teacher_id',
				array(
					'size' => 20,
					'value' => $data['teacher_id'],
					'showName' => '教员编号'
				),
				true
			),
			'advantage' => $this->_ui->control('Textbox', 'advantage',
				array(
					'size' => 20,
					'value' => $data['advantage'],
					'showName' => '特长学科'
				),
				true
			),
			'stuNum' => $this->_ui->control('Textbox', 'stuNum',
				array(
					'size' => 20,
					'value' => $data['stuNum'],
					'showName' => '学号'
				),
				true
			)
			
		);
		return $form;
	}
	
	function updateForm($data = null) {
		$form = array(
			'charger' => $this->_ui->control('Textbox','charger',
				array(
					'size' => 6,
					'value' => $data['charger'],
					'showName' => '负责人'
				),
				true
			),
			'time' => $this->_ui->control('Textbox', 'time',
				array(
					'size' => 6,
					'value' => $data['time'],
					'showName' => '推荐时间'
				),
				true
			),
			'respon' => $this->_ui->control('Textbox', 'respon',
				array(
					'size' => 40,
					'value' => $data['respon'],
					'showName' => '家长评价'
				),
				true
			)
			
		);
		return $form;
	}
	
	function registerForm($data = null) {
		$form = array(
			'user_id' => $this->_ui->control('Hidden', 'user_id',
				array(
					'value' => $data['user_id']
				),
				true
			),
			'advantage' => $this->_ui->control('Textbox', 'advantage',
				array(
					'size' => 80,
					'value' => $data['advantage']
				),
				true
			),
			'englishLevel' => $this->_ui->control('Textbox', 'englishLevel',
				array(
					'size' => 80,
					'value' => $data['englishLevel']
				),
				true
			),
			'skill' => $this->_ui->control('Textbox', 'skill',
				array(
					'value' => $data['skill']
				),
				true
			),
			'mandarin' => $this->_ui->control('Checkbox', 'mandarin',
				array(
					'value' => 1,
					'checked' => $data['mandarin']
				),
				true
			),
			'cantonese' => $this->_ui->control('Checkbox', 'cantonese',
				array(
					'value' => 1,
					'checked' => $data['cantonese']
				),
				true
			),
			'experience' => $this->_ui->control('Checkbox', 'experience',
				array(
					'value' => 1,
					'checked' => $data['experience']
				),
				true
			),
			'stuType' => $this->_ui->control('CheckboxGroup', 'stuType',
				array(
					'items' => array(
						'小学生' => 0,
						'初中生' => 1,
						'高中生' => 2,
						'成人' => 3
					),
					'selected' => split(',', $data['stuType'])
				),
				true
			),
			'special' => $this->_ui->control('Textbox', 'special',
				array(
					'value' => $data['special']
				),
				true
			),
			'order' => $this->_ui->control('Textbox', 'order',
				array(
					'size' => 80,
					'value' => $data['order']
				),
				true
			),
			'taught' => $this->_ui->control('Textbox', 'taught',
				array(
					'value' => $data['taught']
				),
				true
			),
			'memo' => $this->_ui->control('Memo', 'memo',
				array(
					'rows' => 4,
					'cols' => 73,
					'value' => $data['memo']
				),
				true
			),

			'score' => $this->_ui->control('Textbox', 'score',
				array(
					'required' => 'true',
					'value' => $data['score']
				),
				true
			)
		);
		return $form;
	}
}
